count = 0
for a in range(1, 501):
    if a % 10 != 4  and a // 10 % 10 != 4 and a // 100 % 10 != 4:
        count+=1
print(count)